﻿<UserControl x:Class="Albatross.SharePoint.Explorer.Views.ClientObjectView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:wpfViews="clr-namespace:Albatross.WPF.Common.Views;assembly=Albatross.WPF.Common"
			 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
			 xmlns:system="clr-namespace:System;assembly=mscorlib"
			 xmlns:root="clr-namespace:Albatross.SharePoint.Explorer"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Albatross.SharePoint.Explorer;component/Resources/common.xaml"/>
			</ResourceDictionary.MergedDictionaries>
			<wpfViews:BooleanVisibilityConverter x:Key="bool2visibility"/>
			<wpfViews:NotConverter x:Key="notCvt"/>
			<root:PrettyXmlConverter x:Key="prettyXmlConverter"/>
			<wpfViews:IsNullConverter x:Key="IsNotNullCvt" Reversed="True" />
			<wpfViews:NullVisibilityConverter x:Key="NullVisibilityCvt" />
		</ResourceDictionary>
	</UserControl.Resources>
    
	<Grid IsEnabled="{Binding IsLoading, Converter={StaticResource notCvt}}">
		<Border Background="Lavender">
			<DockPanel>
				<TextBlock DockPanel.Dock="Top" Text="{Binding Title, FallbackValue=ObjectName}" Background="Lavender" FontSize="14" Margin="5"/>
				<Grid DockPanel.Dock="Top" Margin="5 0 5 0">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*"/>
						<ColumnDefinition Width="Auto"/>
					</Grid.ColumnDefinitions>
					<TextBlock DockPanel.Dock="Top" Text="{Binding TypeName, FallbackValue=TypeName}" Background="Lavender" FontSize="12" Margin="5"/>
					<TextBlock Grid.Column="1" VerticalAlignment="Center"><Hyperlink NavigateUri="{Binding MSDNUrl}" RequestNavigate="Hyperlink_RequestNavigate">MSDN</Hyperlink></TextBlock>
				</Grid>
				<TabControl x:Name="Tabs" Background="Transparent" SelectionChanged="Tabs_SelectionChanged">
					<TabItem Header="Properties" Background="Transparent">
						<DataGrid Style="{StaticResource DataGridStyle}" DockPanel.Dock="Bottom" Margin="5"
						  ItemsSource="{Binding Properties}" AutoGenerateColumns="False" SelectionMode="Extended" 
						  SelectionUnit="FullRow" CanUserResizeColumns="True" CanUserResizeRows="True" BorderBrush="Silver">
							<DataGrid.Columns>
								<DataGridTextColumn Binding="{Binding Name, Mode=OneWay}" Header="Property Name" Width="1*"/>
								<DataGridTextColumn Binding="{Binding Value, Mode=OneWay}" Header="Value" Width="1*"/>
								<DataGridTextColumn Binding="{Binding Type, Mode=OneWay}" Header="Type" Width="Auto"/>
							</DataGrid.Columns>
						</DataGrid>
					</TabItem>
					<TabItem Header="SchemaXml" Visibility="{Binding HasSchemaXml, Converter={StaticResource bool2visibility}}">
						<FlowDocumentReader ViewingMode="Scroll" Document="{Binding SchemaXml, Converter={StaticResource prettyXmlConverter}}"/>
					</TabItem>
					<TabItem Header="Error" IsSelected="{Binding Error, Converter={StaticResource IsNotNullCvt}, Mode=OneWay}" Visibility="{Binding Error, Converter={StaticResource NullVisibilityCvt}}">
						<DockPanel>
							<TextBlock DockPanel.Dock="Top" Margin="5" FontSize="12">An error has occurred while loading the values from the server.  Try clearing the error by Reloading!</TextBlock>
							<TextBox DockPanel.Dock="Top" Background="Transparent" BorderThickness="0" Margin="5" Padding="0" FontSize="12" IsReadOnly="True"
									 TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Error, Mode=OneWay}" Foreground="Red" />
						</DockPanel>
					</TabItem>
				</TabControl>
			</DockPanel>
		</Border>
		<wpfViews:LoadingView Visibility="{Binding IsLoading, Converter={StaticResource bool2visibility}}" />
	</Grid>
</UserControl>
